import 'package:flutter/material.dart';

class Example {
  static Widget principleExample() {
    return Center(
      child: Container(
        child: Row(
          children: [
            Column(
              children: [
                Icon(
                  Icons.account_circle,
                  color: Colors.red,
                  size: 60,
                ),
                Container(
                  child: Text("实例"),
                )
              ],
            ),
            Column(
              children: [
                Icon(
                  Icons.account_circle,
                  color: Colors.green,
                  size: 60,
                ),
                Container(
                  child: Text("实例"),
                )
              ],
            ),
            Column(
              children: [
                Icon(
                  Icons.account_circle,
                  color: Colors.blue,
                  size: 60,
                ),
                Container(
                  child: Text("实例"),
                )
              ],
            ),
          ],
        ),
      ),
    );
  }

  static Widget stack() {
    return Center(
      child: Container(
        width: 300,
        height: 400,
        color: Colors.grey,
        child: Stack(
          children: [
            Positioned(
              top: 30,
              left: 50,
              child: Icon(
                Icons.home,
                size: 50,
                color: Colors.red,
              ),
            ),
            Positioned(
              top: 60,
              right: 80,
              child: Icon(
                Icons.star,
                size: 50,
                color: Colors.green,
              ),
            ),
            Positioned(
              bottom: 50,
              right: 50,
              child: Icon(
                Icons.send,
                size: 50,
                color: Colors.blue,
              ),
            ),
          ],
        ),
      ),
    );
  }

  static Widget expanded() {
    return Center(
      child: Row(
        children: [
          Expanded(
            child: Image.network(
                "https://scpic.chinaz.net/files/pic/pic9/202012/apic29904.jpg"),
          ),
          Expanded(
            flex: 2,
            child: Image.network(
                "https://scpic.chinaz.net/files/pic/pic9/202011/hpic3172.jpg"),
          ),
          Expanded(
            child: Image.network(
                "https://scpic.chinaz.net/files/pic/pic9/202101/bpic22167.jpg"),
          ),
        ],
      ),
    );
  }

  static Widget gather() {
    return Center(
      child: Row(
        mainAxisSize: MainAxisSize.min,
        children: [
          Icon(Icons.star, color: Colors.green[500]),
          Icon(Icons.star, color: Colors.green[500]),
          Icon(Icons.star, color: Colors.green[500]),
          Icon(Icons.star, color: Colors.black),
          Icon(Icons.star, color: Colors.black),
        ],
      ),
    );
  }

  static Widget gridView() {
    Widget _createGridViewItem(Color color){
      return Container(
        height: 80,
        color: color,
      );
    }
    return Center(
      child: GridView(
        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
          crossAxisCount: 3,
          crossAxisSpacing: 4,
          mainAxisSpacing: 4
        ),
        children: [
          _createGridViewItem(Colors.blue),
          _createGridViewItem(Colors.amber),
          _createGridViewItem(Colors.lightBlueAccent),
          _createGridViewItem(Colors.yellow),
          _createGridViewItem(Colors.greenAccent),
          _createGridViewItem(Colors.purpleAccent),
          _createGridViewItem(Colors.brown),
          _createGridViewItem(Colors.green),
        ],
      )
    );
  }

  static Widget cardAndListTile(){
    Widget _card(String name){
      return Card(
        child: Column(
          children: [
            ListTile(
              leading: Container(
                width: 45,
                height: 45,
                child: Image.network("https://scpic.chinaz.net/files/pic/pic9/202010/apic28588.jpg"),
              ),
              trailing: Icon(Icons.sort),
              title: Text(name),
              subtitle: Text("这个家伙很懒，什么都没写"),
            ),
          ],
        ),
      );
    }
    return ListView(
      children: [
        _card("张三"),
        _card("李四"),
      ],
    );
  }

  static Widget shoushi(){
    return GestureDetector(
      onDoubleTap: (){

      },
    );
  }
}
